home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / stasplit / mainfrm.cpp next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.3 KB  |  130 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stasplit.h"
  6. #include "staspdoc.h"
  7. #include "staspvw.h"
  8.  
  9. #include "mainfrm.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CNestedSplitterWnd
  18.  
  19. // This overridden function ensures that new views are created correctly,
  20. // since the wrong active view at the time of the split could cause an
  21. // empty document to be attached to the new pane
  22.  
  23. BOOL CNestedSplitterWnd::SplitRow (int cyBefore)
  24. {
  25.     ((CMainFrame*)AfxGetMainWnd())->SetActiveView((CView*)GetPane(0, 0));
  26.     return CSplitterWnd::SplitRow(cyBefore);
  27. }
  28.  
  29. BOOL CNestedSplitterWnd::SplitColumn(int cxBefore)
  30. {
  31.     ((CMainFrame*)AfxGetMainWnd())->SetActiveView((CView*)GetPane(0, 0));
  32.     return CSplitterWnd::SplitColumn(cxBefore);
  33. }
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CMainFrame
  37.  
  38. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  39.  
  40. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  41.     //{{AFX_MSG_MAP(CMainFrame)
  42.     ON_WM_CREATE()
  43.     //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CMainFrame construction/destruction
  48.  
  49. CMainFrame::CMainFrame()
  50. {
  51. }
  52.  
  53. CMainFrame::~CMainFrame()
  54. {
  55. }
  56.  
  57. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  58. {
  59.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  60.         return -1;
  61.  
  62. #if (_WIN32_WCE > 200)
  63.     if(!m_wndCommandBar.Create(this) ||
  64.        !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
  65.        !m_wndCommandBar.AddAdornments())
  66.     {
  67.         TRACE0("Failed to create CommandBar\n");
  68.         return -1;      // fail to create
  69.     }
  70. #else // MFC for Windows CE 1.0 and 2.0
  71.     if(!AddAdornments(0))
  72.     {
  73.         TRACE0("Failed to create CommandBar\n");
  74.         return -1;      // fail to create
  75.     }
  76. #endif
  77.  
  78.     return 0;
  79. }
  80.  
  81. //#define WCE_DYNAMIC_SPLITTER // comment this out to change the sample to use dynamic splitters.
  82.  
  83. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  84.     CCreateContext* pContext)
  85. {
  86. #if defined(WCE_DYNAMIC_SPLITTER)
  87.     SIZE sz = {40,40};
  88.     if(!m_wndSplitter1.Create(this, 2, 2, sz, pContext))
  89. #else
  90.     if(!m_wndSplitter1.CreateStatic(this, 2, 2))
  91. #endif // WCE_DYNAMIC_SPLITTER
  92.         return FALSE;
  93.  
  94.     // *, 0 are static splitter windows
  95. #if !defined(WCE_DYNAMIC_SPLITTER)
  96.     for (int nRow = 0; nRow < 2; nRow++)
  97.     {
  98.         if (!m_wndSplitter1.CreateView(nRow, 0,    RUNTIME_CLASS(CStaticSplitView), CSize(100, 100), pContext))
  99.             return FALSE;
  100.     }
  101.     // 0, 1 is also a static splitter window
  102.     if (!m_wndSplitter1.CreateView(0, 1, RUNTIME_CLASS(CStaticSplitView), CSize(100, 100), pContext))
  103.         return FALSE;
  104.  
  105.     if (!m_wndSplitter1.CreateView(1, 1, RUNTIME_CLASS(CStaticSplitView), CSize(100, 100), pContext))
  106.         return FALSE;
  107. #endif // WCE_DYNAMIC_SPLITTER
  108.     return TRUE;
  109. }                                     
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CMainFrame diagnostics
  113.  
  114. #ifdef _DEBUG
  115. void CMainFrame::AssertValid() const
  116. {
  117.     CFrameWnd::AssertValid();
  118. }
  119.  
  120. void CMainFrame::Dump(CDumpContext& dc) const
  121. {
  122.     CFrameWnd::Dump(dc);
  123. }
  124.  
  125. #endif //_DEBUG
  126.  
  127. /////////////////////////////////////////////////////////////////////////////
  128. // CMainFrame message handlers
  129.  
  130.